#ifndef SQL_H
#define SQL_H

#include <QtCore>
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlQuery>

class sql
{
public:
    ~sql();

    bool connect(const QString &host, const qint32 &port,
                 const QString &username, const QString &pwd, const QString &db_name);

    bool insert_user(QString user, QString pwd);

    bool insert_song(QString song_name, QString path);

    bool insert_user_song(QString user, QString song_name);

    bool insert_lrc(QString lrc_name, QString path);

    bool insert_song_lrc(QString song_name, QString lrc_name);

    bool select_user_and_pwd(QString user, QString pwd);

    std::unordered_map<QString, QString> select_song_name_and_path(QString user);

    std::unordered_map<QString, QString> select_song_lrc_and_path(QString song_name);

    QString select_lrc_path(QString song_name);

    bool  delete_song(QString song_name);

    bool is_open() const;

    void disconnect();

    bool is_open_ = false;
private:
    QString host;
    qint32 port;
    QString username;
    QString pwd;
    QString db_name;

    QString connection_name;
};

#endif // SQL_H
